@include('backstage/public/_header')
    <style>
        .add_tab td span #thume {
            line-height: 100px;
            color: #d94040;
            font-size: 14px;
            text-align: center;
        }
    </style>
    <div class="result_wrap">
        <div class="result_title">
            <div class="mark">
                <p>帶<i class="require">*</i>為必填項</p>
            </div>
        </div>
        <form id="form_data">
            {{csrf_field()}}
            <input type="hidden" name="id" value="{{$user->id}}" />
            <table class="add_tab">
                <tbody>
                    <tr>
                        <th>是否註銷：</th>
                        <td>
                            <label for=""><input type="radio" value="0" name="is_ban" @if($user->is_ban==0) checked="checked" @endif>否</label>
                            <label for=""><input type="radio" value="1" name="is_ban" @if($user->is_ban==1) checked="checked" @endif>是</label>
                            <span color="darkred"><i class="fa fa-exclamation-circle yellow"></i>註銷後會員不能登錄，須聯系客服處理</span>
                        </td>
                    </tr>
                    <tr>
                        <th>是否凍結：</th>
                        <td>
                            <label for=""><input type="radio" value="0" name="is_freeze" @if($user->is_freeze==0) checked="checked" @endif>否</label>
                            <label for=""><input type="radio" value="1" name="is_freeze" @if($user->is_freeze==1) checked="checked" @endif>是</label>
                            <span color="darkred"><i class="fa fa-exclamation-circle yellow"></i>凍結後會員仍然可以得到返現但是不能提現，須聯系客服處理</span>
                        </td>
                    </tr>
                    <tr>
                        <th><i class="require">*</i>新密碼：</th>
                        <td>
                            <input type="text" class="lg" name="user_pass" id="user_pass">
                            <span><i class="fa fa-exclamation-circle yellow"></i>如不修改則留空</span>
                        </td>
                    </tr>
                    <tr>
                        <th><i class="require">*</i>確認新密碼：</th>
                        <td>
                            <input type="text" class="lg" name="re_user_pass" id="re_user_pass">
                        </td>
                    </tr>
                    <tr>
                        <th>用護昵稱：</th>
                        <td>
                            <input type="text" class="lg" name="nickname" id="nickname" value="{{$user->nickname}}">
                        </td>
                    </tr>
                    <tr>
                        <th>真實姓名：</th>
                        <td><input type="text" class="lg" name="family" id="family" placeholder="這裏修改姓氏" style="width: 80px;" value="{{$user->family}}">
                            <input type="text" class="lg" name="name" id="name" placeholder="這裏修改名字" style="width: 160px;" value="{{$user->name}}">
                        </td>
                    </tr>
                        {{--<tr>
                            <th>性別：</th>
                            <td>
                                <label for=""><input type="radio" value="0" name="sex" @if($user->sex==0) checked="checked" @endif>女</label>
                                <label for=""><input type="radio" value="1" name="sex" @if($user->sex==1) checked="checked" @endif>男</label>
                            </td>
                        </tr>--}}
                        {{--<tr>
                            <th><i class="require">*</i>證件簽署日期：</th>
                            <td>
                                <input type="text" class="lg" name="idcard_time" id="idcard_time" value="{{$user->idcard_time}}">
                                <span color="darkred"><i class="fa fa-exclamation-circle yellow"></i>格式為YYYY-MM-DD，如2016-01-01</span>
                            </td>
                        </tr>
                        <tr>
                            <th>出生日期：</th>
                            <td>
                                <input type="text" class="lg" name="birthday" id="birthday" value="{{$user->birthday}}">
                                <span color="darkred"><i class="fa fa-exclamation-circle yellow"></i>格式為YYYY-MM-DD，如1980-01-01</span>
                            </td>
                        </tr>
                        <tr>
                            <th>通訊地址：</th>
                            <td>
                                <input type="text" class="lg" name="address" id="address" value="{{$user->address}}">
                            </td>
                        </tr>--}}
                    <tr>
                        <th><i class="require">*</i>電話號碼：</th>
                        <td>
                            <input type="text" class="lg" name="user_phone" id="user_phone" value="{{$user->user_phone}}">
                        </td>
                    </tr>
                    <tr>
                        <th><i class="require">*</i>郵箱號碼：</th>
                        <td>
                            <input type="text" class="lg" name="user_email" id="user_email" value="{{$user->user_email}}">
                            <span color="darkred">郵箱可以用於登錄和找回密碼</span>
                        </td>
                    </tr>
                    <tr>
                        <th><i class="require">*</i>持卡銀行名稱：</th>
                        <td>
                            <input type="text" class="lg" name="bank_name" id="bank_name" value="{{$user->bank_name}}">
                        </td>
                    </tr>
                    <tr>
                        <th><i class="require">*</i>銀行帳護號碼：</th>
                        <td>
                            <input type="text" class="lg" name="bank_num" id="bank_num" value="{{$user->bank_num}}">
                        </td>
                    </tr>
                    {{--<tr>
                        <th>往來銀行地址：</th>
                        <td>
                            <input type="text" class="lg" name="bank_address" id="bank_address" value="{{$user->bank_address}}">
                        </td>
                    </tr>--}}
                    <tr>
                        <th><i class="require">*</i>持有人姓名：</th>
                        <td>
                            <input type="text" class="lg" name="bank_owner" id="bank_owner" value="{{$user->bank_owner}}">
                        </td>
                    </tr>
                    <tr>
                        <th>證件號碼：</th>
                        <td>
                            <input type="text" class="lg" name="idcard" id="idcard" value="{{$user->idcard}}">
                            <span color="darkred"><i class="fa fa-exclamation-circle yellow"></i>可填寫護照或身份證號碼</span>
                        </td>
                    </tr>
                    <tr>
                        <th>證件图（正面）：</th>   
                        <td>
                            <input type="file" name="idcard_img" id="idcard_img" style="float: left;margin-top: 40px;">
                            <span style="float:left">
                                <div style="text-align:center; clear:both; overflow:hidden; width:290px; height:100px">
                                    <span id="thume" @if($user->idcard_img!='') style="display:none;" @endif >無縮略圖</span>
                                    <a id="hrefimg"  target="_blank" @if($user->idcard_img=='') style="display:none;" @endif href="@if($user->idcard_img) http://{{ $_SERVER['SERVER_NAME'].$user->idcard_img }} @endif">
                                        <img id="srcimg" src="@if($user->idcard_img) http://{{ $_SERVER['SERVER_NAME'].$user->idcard_img }} @endif" height="100" alt="圖片預覽" />
                                    </a>
                                </div>
                            </span>
                        </td>
                    </tr>
                </tbody>
            </table>
            <div class="btn_group">
                <input type="button" value="確定" id="btnSub" onclick="onSubmit();">
                <input type="button" class="back" onclick="history.go(-1)" value="返回">
            </div>
        </form>
        <div class="tips">
            <h3>修改用護信息說明</h3>
            <p>1、沒有特殊情況，請不要隨意修改用護資料</p>
            <p>2、帶<i class="require">*</i>為必填項，如不修改則留空，但是密碼至少6位字符</p>
            <p>3、點擊確定 -&gt; 修改用護信息，返回-&gt; 回到會員列表</p>
        </div>
    </div>
    <script type="text/javascript">
        $('#user_content').bind('input propertychange', function(){
            var val = $('#user_content').val();
            $(document.getElementById('preview').contentWindow.document.body).html(val);
        });
        $('#user_content').trigger("input");
        $('#idcard_img').click(function(){

            document.getElementById('srcimg').src = '';

            document.getElementById('hrefimg').href= '';

            document.getElementById('idcard_img').value= '';

            $("#hrefimg").hide();

            $("#thume").show();

        });
        $('#idcard_img').change(function(){

            var f = document.getElementById('idcard_img').files[0];

            var url = window.URL.createObjectURL(f);

            document.getElementById('srcimg').src = url;

            document.getElementById('hrefimg').href = url;

            if($('#imgfile').val()==""){

                $("#hrefimg").hide();

                $("#thume").show();

            }else{

                $("#hrefimg").show();

                $("#thume").hide();

            }

        });
        var vfTime = 2;
        var timer=null;
        function setTime(){
            vfTime --;
            if(vfTime<=0){
                vfTime = 0;
                clearInterval(timer);
            }
        }
        function onSubmit(){
            var pass = $("#user_pass").val();
            var re_pass = $("#re_user_pass").val();
            var idcard = $("#idcard").val();
            // var idcard_time = $("#idcard_time").val();
            var user_phone = $("#user_phone").val();
            var user_email = $("#user_email").val();
            var bank_name = $("#bank_name").val();
            var bank_num = $("#bank_num").val();
            var bank_owner = $("#bank_owner").val();
            if (vfTime!=0 && timer!=null){
                layer.msg('操作過於頻繁', {icon: 7,anim: 6});
                return false;
            }
            if( (pass!=""||re_pass!="") && re_pass!=pass){
                setTimeout(function(){$('#re_user_pass').focus();},0);
                layer.msg('新密碼和確認密碼不相同，如不修改則都留空', {icon: 5,anim: 6});
                return false;
            }
            // if(idcard_time==''){
            //     setTimeout(function(){$('#idcard_time').focus();},0);
            //     layer.msg('證件簽署日期不能為空', {icon: 5,anim: 6});
            //     return false;
            // }
            if(user_phone==''){
                setTimeout(function(){$('#user_phone').focus();},0);
                layer.msg('電話號碼不能為空', {icon: 5,anim: 6});
                return false;
            }
            if(user_email==''){
                setTimeout(function(){$('#user_email').focus();},0);
                layer.msg('郵箱號碼不能為空', {icon: 5,anim: 6});
                return false;
            }
            if(bank_name==''){
                setTimeout(function(){$('#bank_name').focus();},0);
                layer.msg('持卡銀行名稱不能為空', {icon: 5,anim: 6});
                return false;
            }
            if(bank_num==''){
                setTimeout(function(){$('#bank_num').focus();},0);
                layer.msg('銀行帳護號碼不能為空', {icon: 5,anim: 6});
                return false;
            }
            if(bank_owner==''){
                setTimeout(function(){$('#bank_owner').focus();},0);
                layer.msg('持有人姓名不能為空', {icon: 5,anim: 6});
                return false;
            }
            if(idcard==''){
                setTimeout(function(){$('#idcard').focus();},0);
                layer.msg('證件號碼不能為空', {icon: 5,anim: 6});
                return false;
            }
            var form = new FormData(document.getElementById("form_data"));
            $.ajax({
                url:"{{$doedit}}",
                type:"post",
                data:form,
                processData:false,
                contentType:false,
                dataType : "json",
                success:function(data){
                    if(data.status==1){
                        layer.msg(data.message, {icon: 6});
                        setTimeout(function(){
                            window.location.href=data.jumpUrl;
                        },2000);
                    }else if(data.status==-1){
                        layer.alert(data.message, {icon: 2,anim:6});
                        
                    }else{
                        layer.msg(data.message, {icon: 5});
                    }
                    
                    clearInterval(timer);
                    timer = setInterval(setTime, 1000, "1");
                    
                },
                error:function(e){
                    layer.msg(e, {icon: 5,anim: 6});
                    clearInterval(timer);
                    timer = setInterval(setTime, 1000, "1");
                }
            });
        }
    </script>
@include('backstage/public/_footer')